<?php

class IndexController extends CommonController
{
    var $model;

    function __construct()
    {
        parent::__construct();
        $this->model = D();
        $this->sidebar();
    }

    function sidebar()
    {
        $sidebar = $this->model->sidebar();
        $this->assign('categories', $sidebar['categories']);
        $this->assign('last_articles', $sidebar['last_articles']);
        $this->assign('last_comments', $sidebar['last_comments']);
    }

    function index()
    {
        $articles = $this->model->all_articles();
        $this->assign('articles', $articles);
        $this->display();
    }

    function create()
    {
        $this->display();
    }

    function store()
    {
        if ($this->model->store_article()) {
            $this->jump('index.php', '添加成功');
        }

        $this->jump('', '添加失败,请于管理员联系');
    }



}

